package com.fgr.mapper;

import com.fgr.beans.AnimalType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AnimalTypeMapper {
    @Select("select * from an_type")
    public List<AnimalType> selectAllAnimalType();

    @Select("select * from an_type where ty_id=#{tyId}")
    public AnimalType selectAnimalTypeById(Integer tyId);

    @Select("select * from an_type where ty_parent_id=#{tyParentId}")
    public List<AnimalType> selectAllAnimalTypeByParentType(Integer tyParentId);

    @Select("select * from an_type where ty_parent_id!=0")
    public List<AnimalType> selectAllAnimalChildType();

    @Delete("delete from an_type where ty_id=#{ty_id}")
    public Integer deleteAnimalType(Integer ty_id);

    //删除父类下的子类
    @Delete("delete from an_type where ty_parent_id=#{ty_id}")
    public Integer deleteAnimalTypeByParentId(Integer ty_id);

    @Insert("insert into an_type(ty_name,ty_parent_id) values(#{tyName},#{tyParentId})")
    public Integer insertAnimalType(AnimalType animalType);
}
